<?php
$id = $_POST['id'];
$user = $_POST['user'];
$time = date('Y-m-d H:i:s');
$conn = new mysqli("localhost", "root", "", "simple_weibo");
$conn->query("set names 'utf8'");

$sql = "insert into weibo_zan(user, time, weibo_id) values ('".$user."', '".$time."', ".$id.")";
$res = $conn->query($sql);

if($res){
    $hotsql = "update weibo_list set weibo_zan=weibo_zan+1, weibo_hot=weibo_hot+1 where weibo_id='".$id."'";
    $hotres = $conn->query($hotsql);
    echo "点赞成功";
}else {
    echo "点赞失败";
}

// echo $time;

// echo $id.$user;

// echo "点赞";